// components/navbar/navbar.ts
import { background_url } from '../../utils/constant'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: ''
    },
    showBackgroundImage: {
      type: Boolean,
      value: true,
    },
    backgroundColor: {
      type: String,
      value: ''
    },
    logo: {
      type: String,
      value: ''
    },
    showBack: {
      type: Boolean,
      value: true
    },
    barColor: {
      type: String,
      value: "#fff"
    },
    showContentBg: {
      type: Boolean,
      value: true
    },
    // 商城文字
    desc: {
      type: String
    },
    height: {
      type: String,
      value: "auto"
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    statusHeight: 0 as number,
    navHeight: 0 as number,
    url: '' as string
  },

  /**
   * 组件的方法列表
   */
  methods: {
    navigateBack() {
      console.log(getCurrentPages())
      if (getCurrentPages().length > 1) {
        wx.navigateBack();
      } else {
        wx.switchTab({
          url: '/pages/index/index'
        })
      }
    }
  },
  attached() {
    const app = getApp<IAppOption>();
    this.setData({
      statusHeight: app.globalData.statusBarHeight,
      navHeight: app.globalData.navHeight,
      url: background_url
    })
  },
})